package example.multi.service;

import blingking.jfinal.orm.annotation.JFinalORMTx;
import com.jfinal.plugin.activerecord.Db;
import example.multi.model.Torder;
import example.multi.model.TorderSecond;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class OrderService {

    @JFinalORMTx(dataSources = {"ds1","ds2"})
    public boolean addOrder(){
        Db.use("ds1").template("addOrder",new BigDecimal("111"),1,"1111").update();

        Db.use("ds1").template("addOrder2",new BigDecimal("333"),3,"3333").update();

        Db.use("ds2").template("addOrderSecond",new BigDecimal("555"),5,"5555").update();

        Db.use("ds2").template("addOrderSecond2",new BigDecimal("6666"),6,"6666").update();

        Torder torder = new Torder();
        torder.setGoodsId(2);
        torder.setOrderNum("222222");
        torder.setAmount(new BigDecimal("222"));
        torder.save();

        TorderSecond torder2 = new TorderSecond();
        torder2.setGoodsId(2);
        torder2.setOrderNum("222222");
        torder2.setAmount(new BigDecimal("222"));
        boolean bool = torder2.save();
        return bool;
    }
}
